<template>
    <div class="home-wrapper">
        <project-menu :detail="projectDetail" :pid="projectId"></project-menu>
        <div class="filters-wrapper">
            <div class="title total_title">个人素材库 - 素材库</div>
            <el-row type="flex">
                <el-radio-group v-model="librarytype" style="margin-bottom: 20px;">
                    <el-radio-button label="all">全部素材</el-radio-button>
                    <el-radio-button label="horviedo">横版视频</el-radio-button>
                    <el-radio-button label="vervideo">竖版视频</el-radio-button>
                    <el-radio-button label="horimg">横版大图</el-radio-button>
                    <el-radio-button label="verimg">竖版大图</el-radio-button>
                </el-radio-group>
            </el-row>
            <el-row type="flex" justify="start" align="middle">
                <div class="form-wrapper" style="width: 300px;margin: 0 10px 0;">
                    <el-input placeholder="请输入创意包名称" size="small" v-model="jd_search" class="input-with-select">
                        <el-button slot="append" icon="el-icon-search"></el-button>
                    </el-input>
                </div>
                <el-button size="small" type="primary" @click="addmaterial = true">上传素材</el-button>
                <el-button size="small">反选</el-button>
                <el-button size="small" type="danger" @click="handsc">删除</el-button>
            </el-row>
            <div class="library_wrap">
                <div class="library_list" v-for="(library, index) in librarys" :key="index">
                    <div class="library_card">
                        <video class="library_list_video" controls v-if="library.video !== undefined">
                            <source :src="library.video" type="video/mp4"></video>
                        <el-image fit="contain" class="library_list_img" :src="library.img"></el-image>
                    </div>
                    <div class="library_card_name">
                        <el-checkbox :key="library.id">{{library.titile}}</el-checkbox>
                    </div>
                    <el-dropdown class="library_card_state">
                        <span class="el-dropdown-link">
                            更多操作<i class="el-icon-arrow-down el-icon--right"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>推送</el-dropdown-item>
                            <el-dropdown-item>删除</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </div>
            <!-- 分割线 -->
            <el-dialog title="上传素材" :visible.sync="addmaterial" width="70%" center>
                <el-tabs v-model="uploadlibrary">
                    <el-tab-pane label="横版视频" name="1">
                        <el-row type="flex" align="middle" justify="center">
                            <el-upload class="add_upload" drag action="" multiple>
                                <i class="el-icon-upload"></i>
                                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                                <div class="el-upload__tip" slot="tip">
                                    <p>横版视频：宽高比16:9，视频码率≥516kbps，大小≤1000M，分辨率≥1280x720</p>
                                    <br/>
                                </div>
                            </el-upload>
                        </el-row>
                    </el-tab-pane>
                    <el-tab-pane label="竖版视频" name="2">
                        <el-row type="flex" align="middle" justify="center">
                            <el-upload class="add_upload" drag action="" multiple>
                                <i class="el-icon-upload"></i>
                                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                                <div class="el-upload__tip" slot="tip">
                                    <p>竖版视频：宽高比9:16，视频码率≥516kbps，大小≤1000M，分辨率≥720x1280</p>
                                    <br/>
                                </div>
                            </el-upload>
                        </el-row>
                    </el-tab-pane>
                    <el-tab-pane label="横版大图" name="3">
                        <el-row type="flex" align="middle" justify="center">
                            <el-upload class="add_upload" drag action="" multiple>
                                <i class="el-icon-upload"></i>
                                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                                <div class="el-upload__tip" slot="tip">
                                    <p>横版大图：宽高比16:9,1280*720≤尺寸≤2560*1440,支持JPG、PNG等图片格式</p>
                                    <br/>
                                </div>
                            </el-upload>
                        </el-row>
                    </el-tab-pane>
                    <el-tab-pane label="竖版大图" name="4">
                        <el-row type="flex" align="middle" justify="center">
                            <el-upload class="add_upload" drag action="" multiple>
                                <i class="el-icon-upload"></i>
                                <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                                <div class="el-upload__tip" slot="tip">
                                    <p>竖版大图：宽高比9:16,720*1280≤尺寸≤1440*2560,支持JPG、PNG等图片格式</p>
                                    <br/>
                                </div>
                            </el-upload>
                        </el-row>
                    </el-tab-pane>
                </el-tabs>
                <el-row type="flex" align="middle" justify="center">
                    <el-button size="small" @click="addmaterial = false">取 消</el-button>
                    <el-button size="small" type="primary" @click="addmaterial = false">确定</el-button>
                </el-row>
            </el-dialog>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                projectId: 0,
                projectDetail: {},
                librarytype: 'all',
                jd_search: '',
                librarychek: '',
                librarys: [],
                checks: [],
                addmaterial: false,
                uploadlibrary:'1'
            }
        },
        mounted() {
            this.loadData()
        },
        methods: {
            loadData() {
                this.$axios.get('/library/list')
                    .then(e => {
                        this.librarys = e.data.items
                        console.log('======', e.data)
                    })
                    .catch(err => {
                        console.log('======', err)
                    })
            },
            handsc() {
                this.$confirm('此操作将删除该素材, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$message({
                        type: 'success',
                        message: '删除成功!'
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            }
        }
    }
</script>